﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ICalendar.CalendarProperties
{
    /// <summary>
    /// This property defines the revision sequence number of the calendar component within a sequence of revisions.
    /// </summary>
    /// <remarks>
    /// When a calendar component is created, its sequence number is zero (US-ASCII decimal 48). It is monotonically incremented by the "Organizer's" CUA each time the "Organizer" makes a significant revision to the calendar component. When the "Organizer" makes changes to one of the following properties, the sequence number MUST be incremented:
    /// 
    /// . "DTSTART"
    /// 
    /// . "DTEND"
    /// 
    /// . "DUE"
    /// 
    /// . "RDATE"
    /// 
    /// . "RRULE"
    /// 
    /// . "EXDATE"
    /// 
    /// . "EXRULE"
    /// 
    /// . "STATUS"
    /// 
    /// In addition, changes made by the "Organizer" to other properties can also force the sequence number to be incremented. The "Organizer" CUA MUST increment the sequence number when ever it makes changes to properties in the calendar component that the "Organizer" deems will jeopardize the validity of the participation status of the "Attendees". For example, changing the location of a meeting from one locale to another distant locale could effectively impact the participation status of the "Attendees".
    /// 
    /// The "Organizer" includes this property in an iCalendar object that it sends to an "Attendee" to specify the current version of the calendar component.
    /// 
    /// The "Attendee" includes this property in an iCalendar object that it sends to the "Organizer" to specify the version of the calendar component that the "Attendee" is referring to.
    /// 
    /// A change to the sequence number is not the mechanism that an "Organizer" uses to request a response from the "Attendees". The "RSVP" parameter on the "ATTENDEE" property is used by the "Organizer" to indicate that a response from the "Attendees" is requested.
    /// </remarks>
    [Serializable]
    [XmlRoot("sequence")]
    public class Sequence : CalendarPropertyBase<int>
    {
        public Sequence()
        {
            
        }

        public Sequence(int value) : base(value)
        {
            
        }

        #region Overrides of CalendarPropertyBase<int>

        protected override void SetValue(string value)
        {
            Value = string.IsNullOrEmpty(value) ? 0 : Convert.ToInt32(value);
        }

        protected override string GetValue()
        {
            return Value.ToString();
        }

        protected override void SetParametersFromXParameters(XParameterCollection xparams)
        {

        }

        protected override XParameterCollection GetXParametersFromParameters()
        {
            return null;
        }

        protected override string[] GetXReservedParametersNames()
        {
            return null;
        }

        public static implicit operator Sequence(int value)
        {
            return new Sequence(value);
        }

        #endregion
    }
}
